/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Emmanuel
 */
@Entity
@Table(name = "post", catalog = "bloodhound", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Post.findAll", query = "SELECT p FROM Post p"),
    @NamedQuery(name = "Post.findByIdContentIndex", query = "SELECT p FROM Post p WHERE p.postPK.idContentIndex = :idContentIndex"),
    @NamedQuery(name = "Post.findByIdContentPage", query = "SELECT p FROM Post p WHERE p.postPK.idContentPage = :idContentPage"),
    @NamedQuery(name = "Post.findByPeso", query = "SELECT p FROM Post p WHERE p.peso = :peso")})
public class Post implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PostPK postPK;
    @Column(name = "peso")
    private Integer peso;
    @JoinColumn(name = "idContentPage", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Contentpage contentpage;
    @JoinColumn(name = "idContentIndex", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Contentindex contentindex;

    public Post() {
    }

    public Post(PostPK postPK) {
        this.postPK = postPK;
    }

    public Post(int idContentIndex, int idContentPage) {
        this.postPK = new PostPK(idContentIndex, idContentPage);
    }

    public PostPK getPostPK() {
        return postPK;
    }

    public void setPostPK(PostPK postPK) {
        this.postPK = postPK;
    }

    public Integer getPeso() {
        return peso;
    }

    public void setPeso(Integer peso) {
        this.peso = peso;
    }

    public Contentpage getContentpage() {
        return contentpage;
    }

    public void setContentpage(Contentpage contentpage) {
        this.contentpage = contentpage;
    }

    public Contentindex getContentindex() {
        return contentindex;
    }

    public void setContentindex(Contentindex contentindex) {
        this.contentindex = contentindex;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (postPK != null ? postPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Post)) {
            return false;
        }
        Post other = (Post) object;
        if ((this.postPK == null && other.postPK != null) || (this.postPK != null && !this.postPK.equals(other.postPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Post[ postPK=" + postPK + " ]";
    }
    
}
